import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.function.Consumer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 对于Lambda的一些练习
 * User: xwl
 * Date: 2023-06-04
 * Time: 19:12
 */
public class Test2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("hello");
        list.add("this");
        list.add("day");
        list.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });
        //
        System.out.println(".........");
        list.forEach(s -> System.out.println(s));
        //
        System.out.println("...........");
//        list.sort(new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return o1.compareTo(o2);
//            }
//        });
        list.sort((o1, o2) ->  o1.compareTo(o2));
        list.forEach(s -> System.out.println(s));

    }
}
